import { request, reqHttp } from './request';
import { StorageApi } from './StorageApi';

export class BaseApi {
	/**
	 * 注册&登录
	 * @link http://pili-yapi.aslan.qa.qiniu.io/project/51/interface/api/1275
	 * @param {Object} data
	 */
	static signUpOrIn(data) {
		return request({
			url: "/v1/signUpOrIn",
			method: "POST",
			data
		})
	}
	
	/**
	 * 获取短信验证码
	 * @link http://pili-yapi.aslan.qa.qiniu.io/project/51/interface/api/1276
	 * @param {Object} data
	 */
	static getSmsCode(data) {
		return request({
			url: "/v1/getSmsCode",
			method: "POST",
			data
		})
	}
	/**
	 * youin 登录  /v1/user/system/login/
	 */
	static youinLogin(data) {
		return reqHttp({
			url: "/v1/user/system/login/",
			method: "POST",
			data
		})
	}
	/**
	 * youin 第三方登录登录  /v1/user/thirdUserInfo/
	 */
	static thirdLogin(data) {
		return reqHttp({
			url: "/v1/user/thirdUserInfo/",
			method: "GET",
			data
		})
	}
	/**
	 * 获取企业信息 /v1/enterprise/enterprise_info/
	 */
	static getEnterpriseInfo(data) {
		return reqHttp({
			url: "/v1/enterprise/enterprise_info/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 创建直播间 /v1/course/system/create_course/
	 */
	static createLive(data) {
		return reqHttp({
			url: "/v1/course/system/create_course/",
			method: "POST",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 直播间列表  预告-- 未开始
	 */
	static getNostartLiveList(data) {
		return reqHttp({
			url: "/v1/portal/frontend/herald_list/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 直播间列表 -- 全部
	 */
	static getLiveAllList(data) {
		return reqHttp({
			url: "/v1/course/system/list_course/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 直播间列表 -- 已结束
	 */
	static getLiveEndList(data) {
		return reqHttp({
			url: "/v1/course/system/over_course/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 获取 七牛 签名token
	 * /v1/course/system/fetch_room_token/
	 */
	static getRoomToken(data) {
		console.log('getRoomToken ',StorageApi.getYouinAuthorization())
		return reqHttp({
			url: "/v1/course/system/fetch_room_token/"+ data.id +"/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 获取推流地址 
	 * /v1/course/system/get_push_url/
	 */
	static getPushUrl(data) {
		console.log('获取推流地址 ',StorageApi.getYouinAuthorization())
		return reqHttp({
			url: "/v1/course/system/get_push_url/"+ data.id +"/",
			method: "GET",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 开始直播 /v1/course/start_living/
	 */
	static startLive(data) {
		return reqHttp({
			url: "/v1/course/start_living/"+ data.id +"/",
			method: "POST",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
	/**
	 * 结束直播 /v1/course/system/end_course/
	 */
	static endLive(data) {
		return reqHttp({
			url: "/v1/course/system/end_course/"+ data.id +"/",
			method: "POST",
			header: {
				Authorization: StorageApi.getYouinAuthorization()
			},
			data
		})
	}
}